import 'package:flutter_bmfmap_example/http/http.dart';

class Marketservice{
  static Future<dynamic> getbannerlist() async {
    var result = await Http.get('/banner');
    return result;
  }

  static getgoodslist(int page) async {
    var response = await Http.get('/commodity/list?pageNum=' + page.toString());
    Map<String,dynamic> result = response;
    print(response);
    return result;
  }

  static getgoodslistbytype(String type,int page) async {
    var response = await Http.get("/commodity/selectByType?type=$type&pageNum=$page");
    Map<String,dynamic> result = response;
    print(response);
    return result;
  }

  static getshoppingcartlist() async {
    var response = await Http.get("/shop");
    return response;
  }

  static getcollectionlist() async {
    var response = await Http.get("/collection/list");
    return response;
  }

  static deletecollection(int id) async {
    var response = await Http.get("/collection/delete?commodityId=$id");
    return response;
  }

  static addcollection(int id) async {
    var response = await Http.get("/collection/add?commodityId=$id");
    return response;
  }

  //添加商品近购物车
  static addshop(int id,int num) async {
    var response = await Http.get("/shop/add?commodityId=$id&commodityNumber=$num");
    return response;
  }

  //从购物车移除商品
  static deleteshop(int id) async {
    var response = await Http.get("/shop/deleteShopById?id=$id");
    return response;
  }

  static addshopnum(int id) async {
    var response = await Http.get("/shop/addByNumber?shopId=$id");
    return response;
  }

  static reduceshopnum(int id) async {
    var response = await Http.get("/shop/reduceByNumber?shopId=$id");
    return response;
  }

  //提交订单
  static postShopBuy(String content,double money) async {
    var response = await Http.post(
        '/shop/buy?content=$content&money=$money');
    return response;
  }

  //提交订单
  static postOrderBuy(String id,String intro,int addressId) async {
    var response = await Http.post(
        '/orderForm/buy?id=$id&intro=$intro&addressId=$addressId');
    return response;
  }

  static getOrederlist() async {
    var response = await Http.get(
        '/orderForm/getAll2');
    return response;
  }

  static getOrederById(String id) async {
    var response = await Http.get(
        '/orderForm/getOrderByID?id=$id');
    return response;
  }

  static  deleteorder(String id) async {
    var response = await Http.post(
        '/orderForm/delete?id=$id');
    return response;
  }
}